﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.ServiceModel;
using System.Workflow.Runtime;
using ClientWorkflowLibrary;

namespace ClientRenderService
{
    public partial class RenderService : ServiceBase
    {
        public RenderService()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Actually does the work. Split to enable testability! :-)
        /// </summary>
        private RenderWFManager _renderManager;

        /// <summary>
        /// Connect up to the remote service so that we can get back
        /// the various data we need.
        /// </summary>
        /// <param name="args"></param>
        protected override void OnStart(string[] args)
        {
            if (_renderManager == null)
            {
                _renderManager = new RenderWFManager();
            }
            _renderManager.Start();
        }

        /// <summary>
        /// The service is shutting down. Make sure everything is good so we can shut down.
        /// </summary>
        protected override void OnStop()
        {
            if (_renderManager != null)
            {
                _renderManager.Stop();
                _renderManager = null;
            }
        }
    }
}
